﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Client.Utility;

namespace SuperviseService
{
    public partial class FrmScreenLock : Form
    {
        public FrmScreenLock()
        {
            InitializeComponent();
        }
       
        private void FrmScreenLock_Load(object sender, EventArgs e)
        {
            SetFullScreen();
            ScreenBlocker.LockScreen(this);
        }

        /// <summary>
        /// 设置窗体满屏显示
        /// </summary>
        private void SetFullScreen()
        {
            this.TopMost = true;
            this.Location = new Point(0, 0);
            this.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;
        }

        /// <summary>
        /// 设置窗体展示后获取焦点（否则Win键会出现）
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPrint(PaintEventArgs e)
        {
            Debug.Write("OnPrint");
            base.OnPrint(e);
            this.Activate();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ScreenBlocker.ReleaseScreen(this);
        }

        /// <summary>
        /// 钩子在处理键盘事件之前调用的delegate所绑定的函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HookInvoked(object sender, HookEventArgs e)
        {
            FCHook h = sender as FCHook;
            if (h != null)
            {
                h.CallNextProc = false;
            }
        }
    }
}
